package com.wn.pettyloan.controller;

import com.wn.pettyloan.dto.DocumentDto;
import com.wn.pettyloan.dto.PayDto;
import com.wn.pettyloan.entity.DocumnetType;
import com.wn.pettyloan.service.DocumentService;
import com.wn.pettyloan.service.DocumentTypeService;
import com.wn.pettyloan.util.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.lang.model.type.DeclaredType;
import java.util.List;
import java.util.Map;

/**
 * @program: pettyloan
 * @ClassName DocumentController
 * @author: lwb
 * @create: 2022-12-09 22:30
 **/
@RestController("/document")
public class DocumentController {

    @Autowired
    private DocumentService documentService;
    @Autowired
    private DocumentTypeService docTypeService;


    @ApiOperation("将已经异步上传的资料传过来")
    @PostMapping("/addDocs")
    public Result addDocs(@RequestBody DocumentDto[] docDtos){
        documentService.batchInsert(docDtos);
        return Result.ok();
    }

    @ApiOperation("查询产品所需要的材料列表")
    @PostMapping("/needDocs/{productId}")
    public Result needDocs(@PathVariable Integer productId){
        List<DocumnetType> docs = docTypeService.selectDocsTypeByProId(productId);
        return Result.ok().data("docs",docs);
    }


}
